package com.web;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.LeaveDTO;

import bizlogic.LeaveManager;

@WebServlet("/deleteLeave")
public class DeleteLeave extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public DeleteLeave() {
        super();
    
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
	
	private void doProcess(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("name");
		System.out.println("Delete");
		System.out.println(username);
		LeaveManager LM = new LeaveManager();
		LeaveDTO LD = LM.findLeave(username);
		System.out.println(LD.getId());
		System.out.println(LD.toString());
		LM.deleteLeave(LD);
		RequestDispatcher rd = request.getRequestDispatcher("/leaveeditview");
		rd.forward(request, response);
	
	}

}
